<?php use_stylesheets_for_form($form) ?>
<?php use_javascripts_for_form($form) ?>
<?php use_javascript('jquery.ui.core.js')?>
<?php use_javascript('jquery.ui.datepicker.js')?>
<?php use_javascript('date.js')?>
<?php use_stylesheet('jquery-ui-1.8.1.custom.css')?>
<?php use_javascript('jquery.calculation.js')?>

<form action="<?php echo url_for('cotizaciones/'.($form->getObject()->isNew() ? 'create' : 'update').(!$form->getObject()->isNew() ? '?id='.$form->getObject()->getId() : '')) ?>" method="post" <?php $form->isMultipart() and print 'enctype="multipart/form-data" ' ?>>
<?php if (!$form->getObject()->isNew()): ?>
<input type="hidden" name="sf_method" value="put" />
<?php endif; ?>
<div id="formulario">
  <table width="100%" style="text-align: left;">
   
   <tbody>
      <?php echo $form->renderGlobalErrors() ?>
      <tr>
        <th><?php echo $form['cuenta_id']->renderLabel() ?></th>
        <th><?php echo $form['proveedor_id']->renderLabel() ?></th>
        <th>Nombre Encargado</th>
        <th><?php echo $form['correo_encargado']->renderLabel() ?></th>
        <th><?php echo $form['anexo_encargado']->renderLabel() ?></th>
      </tr>
      <tr>
        <td><?php echo $form['cuenta_id']->renderError() ?><?php echo $form['estado']?><?php echo $form['cuenta_id'] ?></td>
        <td><?php echo $form['proveedor_id']->renderError() ?> <?php echo $form['proveedor_id'] ?></td>
        <td><?php echo $form['referencia']->renderError() ?> <?php echo $form['referencia'] ?></td>
        <td><?php echo $form['correo_encargado']->renderError() ?> <?php echo $form['correo_encargado'] ?></td>
        <td><?php echo $form['anexo_encargado']->renderError() ?> <?php echo $form['anexo_encargado'] ?></td>
      </tr>
    </tbody>
  <?php if($sf_user->hasCredential('Abastecimiento')):?>
  </table>
	<table width="100%" style="text-algin: left;">
		<tr>
			<th><?php echo $form['sugerencia']->renderLabel() ?></th>
			<th><?php echo $form['plazo_entrega']->renderLabel() ?></th>
		  </tr>
		 <tr>
			<td><?php echo $form['sugerencia']->renderError() ?><?php echo $form['sugerencia'] ?></td>
			<td><?php echo $form['plazo_entrega']->renderError() ?> <?php echo $form['plazo_entrega'] ?></td>
		 </tr>
	</table>
  <?php endif ?>
  <table id="contenedor">
    <thead>
       <tr>
      <th>Art&iacute;culo</th>
      <th>Cantidad</th>
      <th>Observación</th>
      <th>Acciones</th>
    </tr>
    </thead>
	 <tbody>
    <?php if ($form->getObject()->isNew()): ?>
    <script type="text/javascript">newfieldscount = 1;</script>
    <tr>
      <td><?php echo $form['new'][0]['articulo_id']->renderError() ?><?php echo $form['new'][0]['articulo_id'] ?></td>
      <td><?php echo $form['new'][0]['cantidad']->renderError() ?><?php echo $form['new'][0]['cantidad'] ?></td>
      <td><?php echo $form['new'][0]['observacion']->renderError() ?><?php echo $form['new'][0]['observacion'] ?></td>
      <td><a class="removenew" href="#">eliminar</a></td>
    </tr>
    <?php endif ?>
  
  <?php foreach ($form['ItemCotizacionNacional'] as $item):?>
    <tr>
      <td><?php echo $item['articulo_id']->renderError() ?><?php echo $item['articulo_id'] ?></td>
      <td><?php echo $item['cantidad']->renderError() ?><?php echo $item['cantidad'] ?></td>
      <td><?php echo $item['observacion']->renderError() ?><?php echo $item['observacion'] ?></td>
      <td><a class="removenew" href="#">eliminar</a></td>
    </tr>
    <?php endforeach ?>
    
      <tfoot>
    <tr>
      <td><a id="addoccurrence" href="#">Agregar item</a></td>
    </tr>
  </tfoot>
  </tbody>
  
  </table>
  
  <table width="100%">
    <tfoot>
        <td colspan="2">
          <?php echo $form->renderHiddenFields(false) ?>
			<?php echo button_to('Volver', 'cotizaciones/index') ?>
          	<?php if (!$form->getObject()->isNew()): ?>
          		<?php echo link_to('<button>Borrar</button>', 'cotizaciones/delete?id='.$form->getObject()->getId(), array('method' => 'delete', 'confirm' => '¿Está seguro de eliminar?')) ?>
          	<?php endif; ?>
          <input type="submit" value="Guardar" />
        </td>
      </tr>
    </tfoot>
  </table> 
 </div>
</form>



